package com.tledu.zyf.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EncodingFilter extends HttpFilter {
	@Override
	public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		String encoding = getServletContext().getInitParameter("encoding");
		if (encoding == null || encoding.trim().equals("")) {
			encoding = "utf-8";
		}
		request.setCharacterEncoding(encoding);
		response.setCharacterEncoding(encoding);
		chain.doFilter(request, response);
	}

	public void m1() {
		System.out.println("m1---1");
		m2();
		System.out.println("m1---2");
	}

	public void m2() {
		System.out.println(1);
		m3();
		System.out.println(2);
	}

	public void m3() {
		System.out.println(1);
		m4();
		System.out.println(2);
	}

	public void m4() {
		System.out.println(1);
		m5();
		System.out.println(2);
	}

	public void m5() {
		System.out.println("----------");
	}
}
